</div>
<!-- end div class="chapter" -->
<aside class="secondary-navigation"></aside>
</main>

<footer class="site-layout__footer site-footer" itemscope="itemscope" itemtype="https://schema.org/WPFooter">
    <nav class="site-footer__navigation" itemtype="https://schema.org/SiteNavigationElement">
        <section class="site-footer__links">
            <div class="site-footer__link-group">
                <header><strong>Docs</strong></header>
                <ul class="site-footer__links-list">
                    <li itemprop="name"><a href="/userguide/userguide.html" itemprop="url">User Manual</a></li>
                    <li itemprop="name"><a href="/dsl/" itemprop="url">DSL Reference</a></li>
                    <li itemprop="name"><a href="/release-notes.html" itemprop="url">Release Notes</a></li>
                    <li itemprop="name"><a href="/javadoc/" itemprop="url">Javadoc</a></li>
                </ul>
            </div>
            <div class="site-footer__link-group">
                <header><strong>News</strong></header>
                <ul class="site-footer__links-list">
                    <li itemprop="name"><a href="https://blog.gradle.org/" itemprop="url">Blog</a></li>
                    <li itemprop="name"><a href="https://newsletter.gradle.com/" itemprop="url">Newsletter</a></li>
                    <li itemprop="name"><a href="https://twitter.com/gradle" itemprop="url">Twitter</a></li>
                    <li itemprop="name"><a href="https://status.gradle.com/" itemprop="url">Status Page</a></li>
                </ul>
            </div>
            <div class="site-footer__link-group">
                <header><strong>Products</strong></header>
                <ul class="site-footer__links-list">
                    <li itemprop="name"><a href="https://gradle.com/build-scans/" itemprop="url">Build Scans</a></li>
                    <li itemprop="name"><a href="https://gradle.com/build-cache/" itemprop="url">Build Cache</a></li>
                    <li itemprop="name"><a href="https://gradle.com/enterprise/resources/" itemprop="url">Enterprise Docs</a></li>
                </ul>
            </div>
            <div class="site-footer__link-group">
                <header><strong>Get Help</strong></header>
                <ul class="site-footer__links-list">
                    <li itemprop="name"><a href="https://discuss.gradle.org/c/help-discuss" itemprop="url">Forums</a></li>
                    <li itemprop="name"><a href="https://github.com/gradle/" itemprop="url">GitHub</a></li>
                    <li itemprop="name"><a href="https://gradle.com/training/" itemprop="url">Training</a></li>
                    <li itemprop="name"><a href="https://gradle.org/services/" itemprop="url">Services</a></li>
                </ul>
            </div>
        </section>
        <section class="site-footer__subscribe-newsletter" id="newsletter-form-container">
            <header class="newsletter-form__header"><h5>Stay <code>UP-TO-DATE</code> on new features and news</h5></header>
            <p class="disclaimer">By entering your email, you agree to our <a href="https://gradle.com/legal/terms-of-service/">Terms</a> and <a href="https://gradle.com/legal/privacy/">Privacy Policy</a>, including receipt of emails. You can unsubscribe at any time.</p>
            <div class="newsletter-form__container">
                <form id="newsletter-form" class="newsletter-form" action="https://go.gradle.com/l/68052/2018-09-07/bk6wml" method="post">
                    <input id="email" class="email" name="email" type="email" placeholder="name@email.com" pattern="[^@\s]+@[^@\s]+\.[^@\s]+" maxlength="255" required=""/>
                    <button id="submit" class="submit" type="submit">Subscribe</button>
                </form>
            </div>
        </section>
    </nav>
    <div class="site-footer-secondary">
        <div class="site-footer-secondary__contents">
            <div class="site-footer__copy">© <a href="https://gradle.com">Gradle Inc.</a>
                <time>2020</time>
                All rights reserved.
            </div>
            <div class="site-footer__logo"><a href="/">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 90 66.06">
                    <defs>
                        <style>.cls-1 {
                            fill: #02303a;
                        }</style>
                    </defs>
                    <title>gradle</title>
                    <path class="cls-1"
                          d="M85.11,4.18a14.27,14.27,0,0,0-19.83-.34,1.38,1.38,0,0,0,0,2L67,7.6a1.36,1.36,0,0,0,1.78.12A8.18,8.18,0,0,1,79.5,20.06C68.17,31.38,53.05-.36,18.73,16a4.65,4.65,0,0,0-2,6.54l5.89,10.17a4.64,4.64,0,0,0,6.3,1.73l.14-.08-.11.08L31.53,33a60.29,60.29,0,0,0,8.22-6.13,1.44,1.44,0,0,1,1.87-.06h0a1.34,1.34,0,0,1,.06,2A61.61,61.61,0,0,1,33,35.34l-.09,0-2.61,1.46a7.34,7.34,0,0,1-3.61.94,7.45,7.45,0,0,1-6.47-3.71l-5.57-9.61C4,32-2.54,46.56,1,65a1.36,1.36,0,0,0,1.33,1.11H8.61A1.36,1.36,0,0,0,10,64.87a9.29,9.29,0,0,1,18.42,0,1.35,1.35,0,0,0,1.34,1.19H35.9a1.36,1.36,0,0,0,1.34-1.19,9.29,9.29,0,0,1,18.42,0A1.36,1.36,0,0,0,57,66.06H63.1a1.36,1.36,0,0,0,1.36-1.34c.14-8.6,2.46-18.48,9.07-23.43C96.43,24.16,90.41,9.48,85.11,4.18ZM61.76,30.05l-4.37-2.19h0a2.74,2.74,0,1,1,4.37,2.2Z"/>
                </svg>
            </a></div>
            <div class="site-footer-secondary__links">
                <a href="https://gradle.com/careers/">Careers</a> |
                <a href="https://gradle.com/legal/privacy/">Privacy</a> |
                <a href="https://gradle.com/legal/terms-of-service/">Terms of Service</a> |
                <a href="https://gradle.org/contact/">Contact</a>
            </div>
        </div>
    </div>
</footer>

<script type="text/javascript">
    // Polyfill Element.matches()
    if (!Element.prototype.matches) {
        Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
    }
    // Polyfill Element.closest()
    if (!Element.prototype.closest) {
        Element.prototype.closest = function (s) {
            var el = this;
            if (!document.documentElement.contains(el)) return null;
            do {
                if (typeof el.matches === "function" && el.matches(s)) return el;
                el = el.parentElement || el.parentNode;
            } while (el !== null);
            return null;
        };
    }

    var currentChapterFileName = window.location.pathname.substr(window.location.pathname.lastIndexOf("/") + 1);
    if (currentChapterFileName === "index.html" || currentChapterFileName === "") {
        currentChapterFileName = window.location.pathname.substr(0, window.location.pathname.lastIndexOf("/"));
        currentChapterFileName = currentChapterFileName.substr(currentChapterFileName.lastIndexOf("/") + 1) + "/index.html";
    }
    [].forEach.call(document.querySelectorAll(".docs-navigation a[href$='/" + currentChapterFileName + "']"), function (link) {
        // Add "active" to all links same as current URL
        link.classList.add("active");

        // Expand all parent navigation
        var parentListEl = link.closest("li");
        while (parentListEl !== null) {
            var dropDownEl = parentListEl.querySelector(".nav-dropdown");
            if (dropDownEl !== null) {
                dropDownEl.classList.add("expanded");
            }
            parentListEl = parentListEl.parentNode.closest("li");
        }
    });

    // Expand/contract multi-level side navigation
    [].forEach.call(document.querySelectorAll(".docs-navigation .nav-dropdown"), function registerSideNavActions(collapsibleElement) {
        collapsibleElement.addEventListener("click", function toggleExpandedSideNav(evt) {
            evt.preventDefault();
            evt.target.classList.toggle("expanded");
            evt.target.setAttribute("aria-expanded", evt.target.classList.contains("expanded").toString());
            return false;
        }, false);
    });

    function postProcessCodeBlocks() {
        // Assumptions:
        //  1) All siblings that are marked with class="multi-language-sample" should be grouped
        //  2) Only one language can be selected per domain (to allow selection to persist across all docs pages)
        //  3) There is exactly 1 small set of languages to choose from. This does not allow for multiple language preferences. For example, users cannot prefer both Kotlin and ZSH.
        //  4) Only 1 sample of each language can exist in the same collection.

        var GRADLE_DSLs = ["groovy", "kotlin"];
        var preferredBuildScriptLanguage = initPreferredBuildScriptLanguage();

        // Ensure preferred DSL is valid, defaulting to Groovy DSL
        function initPreferredBuildScriptLanguage() {
            var lang = window.localStorage.getItem("preferred-gradle-dsl");
            if (GRADLE_DSLs.indexOf(lang) === -1) {
                window.localStorage.setItem("preferred-gradle-dsl", "groovy");
                lang = "groovy";
            }
            return lang;
        }

        function capitalizeFirstLetter(string) {
            return string.charAt(0).toUpperCase() + string.slice(1);
        }

        function processSampleEl(sampleEl, prefLangId) {
            var codeEl = sampleEl.querySelector("code[data-lang]");
            if (codeEl != null) {
                sampleEl.setAttribute("data-lang", codeEl.getAttribute("data-lang"));
                if (codeEl.getAttribute("data-lang") !== prefLangId) {
                    sampleEl.classList.add("hidden");
                } else {
                    sampleEl.classList.remove("hidden");
                }
            }
        }

        function switchSampleLanguage(languageId) {
            var multiLanguageSampleElements = [].slice.call(document.querySelectorAll(".multi-language-sample"));

            // Array of Arrays, each top-level array representing a single collection of samples
            var multiLanguageSets = [];
            for (var i = 0; i < multiLanguageSampleElements.length; i++) {
                var currentCollection = [multiLanguageSampleElements[i]];
                var currentSampleElement = multiLanguageSampleElements[i];
                processSampleEl(currentSampleElement, languageId);
                while (currentSampleElement.nextElementSibling != null && currentSampleElement.nextElementSibling.classList.contains("multi-language-sample")) {
                    currentCollection.push(currentSampleElement.nextElementSibling);
                    currentSampleElement = currentSampleElement.nextElementSibling;
                    processSampleEl(currentSampleElement, languageId);
                    i++;
                }

                multiLanguageSets.push(currentCollection);
            }

            multiLanguageSets.forEach(function (sampleCollection) {
                // Create selector element if not existing
                if (sampleCollection.length > 1 &&
                    (sampleCollection[0].previousElementSibling == null ||
                        !sampleCollection[0].previousElementSibling.classList.contains("multi-language-selector"))) {
                    var languageSelectorFragment = document.createDocumentFragment();
                    var multiLanguageSelectorElement = document.createElement("div");
                    multiLanguageSelectorElement.classList.add("multi-language-selector");
                    languageSelectorFragment.appendChild(multiLanguageSelectorElement);


                    sampleCollection.forEach(function (sampleEl) {
                        var optionEl = document.createElement("code");
                        var sampleLanguage = sampleEl.getAttribute("data-lang");
                        optionEl.setAttribute("data-lang", sampleLanguage);
                        optionEl.setAttribute("role", "button");
                        optionEl.classList.add("language-option");

                        optionEl.innerText = capitalizeFirstLetter(sampleLanguage);

                        optionEl.addEventListener("click", function updatePreferredLanguage(evt) {
                            var preferredLanguageId = optionEl.getAttribute("data-lang");
                            window.localStorage.setItem("preferred-gradle-dsl", preferredLanguageId);

                            // Record how far down the page the clicked element is before switching all samples
                            var beforeOffset = evt.target.offsetTop;

                            switchSampleLanguage(preferredLanguageId);

                            // Scroll the window to account for content height differences between different sample languages
                            window.scrollBy(0, evt.target.offsetTop - beforeOffset);
                        });
                        multiLanguageSelectorElement.appendChild(optionEl);
                    });
                    sampleCollection[0].parentNode.insertBefore(languageSelectorFragment, sampleCollection[0]);
                }
            });

            [].slice.call(document.querySelectorAll(".multi-language-selector .language-option")).forEach(function (optionEl) {
                if (optionEl.getAttribute("data-lang") === languageId) {
                    optionEl.classList.add("selected");
                } else {
                    optionEl.classList.remove("selected");
                }
            });

            [].slice.call(document.querySelectorAll(".multi-language-text")).forEach(function (el) {
                if (!el.classList.contains("lang-" + languageId)) {
                    el.classList.add("hidden");
                } else {
                    el.classList.remove("hidden");
                }
            });
        }

        switchSampleLanguage(preferredBuildScriptLanguage);
    }

    document.addEventListener("DOMContentLoaded", postProcessCodeBlocks);
</script>
